package com.zuoqi.easywork.system.service;

import com.zuoqi.common.utils.IMap;
import com.zuoqi.easywork.userManage.mapper.TcUserMapper;
import com.zuoqi.easywork.userManage.model.TcUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EasyworkService {
    private static final Logger log = LoggerFactory.getLogger(EasyworkService.class);
    @Autowired
    private TcUserMapper tcUserMapper;

    public Boolean checkLogin(IMap param){
        String username = param.getString( "username");
        String password = param.getString("password");
        TcUser user = tcUserMapper.selectForLogin(username, null);
        if (null != user) {
            if (!password.equals(user.getPassword())) {
                log.info(user.getUserId() + " password invalid");
                return false;
            } else {
                log.info(user.getUserId() + " login success");
                return true;
            }
        }
        return false;
    }
    public TcUser getLoginUser(IMap param){
        String username = param.getString( "username");
        String password = param.getString("password");
        return tcUserMapper.selectForLogin(username, null);
    }
}
